
#ifndef CHESS_MODEL_H
#define CHESS_MODEL_H

#include "Board.h"
#include "MoveHistory.h"
#include <ChessPlayer.h>
#include <HTMLParser.h>

//! The facade that the controller interacts with.  The model.
class ChessModel {
   public:

      //! Constructor
      ChessModel();

      ~ChessModel();

      /**
         * Indicate to the player that the user clicked on the given
         * row and column with the mouse.
         */
      Piece * on_CellSelected(BoardPosition pos, int button=1);

      Piece * GetPiece(BoardPosition pos);

      Piece * RemovePiece(BoardPosition pos);

      void AddOffBoard(Piece * curPiece) {
         offBoardPieces.push_back(curPiece);
      }

      bool AddPiece(BoardPosition pos, Piece * curPiece);

      /**
         * Handle when the user selected the new game button.
         */
      void on_NewGame();

      /**
         * Handle when the user selected the save game button.
         */
      void on_SaveGame();

      /**
         * Handle when the user selected the save game as button.
         */
      void on_SaveGameAs(std::string filename);

      /**
         * Handle when the user selected the load game button.
         */
      void on_LoadGame(std::string filename);

      /**
         * Handle when the user selected the undo move button.
         */
      Move on_UndoMove();

      /**
         * Handle when the user selects to quit the game, either through the
         * quit button, the close X button, or the file menu.
         */
      void on_QuitGame() {}

      Board * GetBoard();
      
      void AddMove(Move m) {
         history->AddMove(m);
      }

   private:
      void Initialize();
      void Destroy();
      Board * myBoard;
      MoveHistory * history;
      std::vector<Piece*> offBoardPieces;
};

#endif
